package com.example.musicplayer.settings;

import android.content.res.Resources;

import com.example.musicplayer.MusicPlayerApplication;
import com.example.musicplayer.R;
import com.example.musicplayer.view.SettingsView;

public class SettingsItem {
    public static final int MUSIC_SETTINGS = 0;
    public static final int PERSONAL_DRESS_UP_CENTER = 1;
    public static final int OPEN_PLATFORM = 2;
    public static final int FREE_SERVICE = 3;
    public static final int TICKETING = 4;
    public static final int COLOR_RING = 5;
    public static final int TIME_TO_EXIT = 6;
    public static final int LISTEN_TO_SONGS = 7;
    public static final int CALCULATOR = 8;
    public static final int GO_BANG = 9;
    public static final int USER_MANAGE = 10;
    public static final int MUSIC_SCORE = 11;

    public static final int ONLY_WIFI = 100;
    public static final int FLOW_REMIND = 101;
    public static final int FLUENCY_SETTINGS = 102;
    public static final int BACKGROUND_SETTINGS = 103;
    public static final int PERSONAL_INFO = 104;
    public static final int AUTO_INTO_PLAY_SCREEN = 105;
    public static final int ALLOW_PLAY_WITH_OTHER = 106;
    public static final int SECURITY_SETTINGS = 107;
    public static final int USE_NOTIFICATION_BAR = 108;
    public static final int DESKTOP_LYRIC = 109;
    public static final int DESKTOP_LYRIC_LOCK = 110;
    public static final int DESKTOP_LYRIC_IN_APP = 111;
    public static final int PLAY_LIST_SETTINGS = 112;

    public static final int TIMED_OFF_IMMEDIATE = 200;

    public static final int USER_PHOTO = 300;
    public static final int USER_NAME = 301;
    public static final int USER_EMAIL = 302;

    public static final int MODIFY_PASSWORD = 400;
    public static final int SET_PASSWORD_PROTECT = 401;

    public static final int ANIM_EFFECT = 500;

    public static final int PLAY_SCREEN_BACKGROUND = 600;
    public static final int MUSIC_PLAY_LIST_BACKGROUND = 601;
    public static final int PLAY_SCREEN_IMAGE = 602;
    public static final int MUSIC_PLAY_LIST_IMAGE = 603;

    public static final int ADD_TO_PLAY_LIST_TAIL = 700;

    public static SettingsView createSettingsItem(int settingsItem) {
        Resources resources = MusicPlayerApplication.getInstance().getResources();
        SettingsView view = null;
        String title = "";
        String summary = null;
        String description = null;
        boolean showSwitch = false;
        switch (settingsItem) {
            case MUSIC_SETTINGS:
                title = resources.getString(R.string.music_settings);
                break;
            case USER_MANAGE:
                title = resources.getString(R.string.user_manage);
                break;
            case PERSONAL_DRESS_UP_CENTER:
                title = resources.getString(R.string.personal_dress_up_center);
                description = resources.getString(R.string.personal_dress_up_center_des);
                break;
            case OPEN_PLATFORM:
                title = resources.getString(R.string.open_platform);
                break;
            case FREE_SERVICE:
                title = resources.getString(R.string.free_service);
                description = resources.getString(R.string.free_service_des);
                break;
            case TICKETING:
                title = resources.getString(R.string.ticketing);
                break;
            case COLOR_RING:
                title = resources.getString(R.string.color_ring);
                description = resources.getString(R.string.color_ring_des);
                break;
            case TIME_TO_EXIT:
                title = resources.getString(R.string.time_to_exit);
                showSwitch = true;
                break;
            case LISTEN_TO_SONGS:
                title = resources.getString(R.string.listen_to_songs);
                break;
            case CALCULATOR:
                title = resources.getString(R.string.music_player_calculator);
                break;
            case GO_BANG:
                title = resources.getString(R.string.music_player_gobang);
                break;
            case MUSIC_SCORE:
                title = resources.getString(R.string.music_score);
                break;
            case ONLY_WIFI:
                title = resources.getString(R.string.only_wifi);
                showSwitch = true;
                break;
            case FLOW_REMIND:
                title = resources.getString(R.string.flow_remind);
                showSwitch = true;
                break;
            case AUTO_INTO_PLAY_SCREEN:
                title = resources.getString(R.string.auto_into_play_screen);
                showSwitch = true;
                break;
            case ALLOW_PLAY_WITH_OTHER:
                title = resources.getString(R.string.allow_play_with_other);
                showSwitch = true;
                break;
            case USE_NOTIFICATION_BAR:
                title = resources.getString(R.string.use_notification_bar);
                showSwitch = true;
                break;
            case DESKTOP_LYRIC:
                title = resources.getString(R.string.use_desktop_lyric);
                showSwitch = true;
                break;
            case DESKTOP_LYRIC_LOCK:
                title = resources.getString(R.string.desktop_lyric_lock);
                showSwitch = true;
                break;
            case DESKTOP_LYRIC_IN_APP:
                title = resources.getString(R.string.desktop_lyric_in_app);
                showSwitch = true;
                break;
            case FLUENCY_SETTINGS:
                title = resources.getString(R.string.fluency_settings);
                break;
            case BACKGROUND_SETTINGS:
                title = resources.getString(R.string.background_settings);
                break;
            case PERSONAL_INFO:
                title = resources.getString(R.string.personal_info);
                break;
            case SECURITY_SETTINGS:
                title = resources.getString(R.string.security_settings);
                break;
            case PLAY_LIST_SETTINGS:
                title = resources.getString(R.string.play_list_settings);
                break;
            case TIMED_OFF_IMMEDIATE:
                title = resources.getString(R.string.timed_off_style_des_2);
                showSwitch = true;
                break;
            case USER_PHOTO:
                title = resources.getString(R.string.user_photo);
                break;
            case USER_NAME:
                title = resources.getString(R.string.user_nick_name);
                break;
            case USER_EMAIL:
                title = resources.getString(R.string.user_email);
                break;
            case MODIFY_PASSWORD:
                title = resources.getString(R.string.modify_password);
                break;
            case SET_PASSWORD_PROTECT:
                title = resources.getString(R.string.set_password_security_question);
                break;
            case ANIM_EFFECT:
                title = resources.getString(R.string.anim_effect);
                summary = resources.getString(R.string.anim_effect_sum);
                showSwitch = true;
                break;
            case PLAY_SCREEN_BACKGROUND:
                title = resources.getString(R.string.play_screen_background);
                summary = resources.getString(R.string.background_default);
                showSwitch = true;
                break;
            case MUSIC_PLAY_LIST_BACKGROUND:
                title = resources.getString(R.string.music_play_list_background);
                summary = resources.getString(R.string.background_default);
                showSwitch = true;
                break;
            case PLAY_SCREEN_IMAGE:
            case MUSIC_PLAY_LIST_IMAGE:
                title = resources.getString(R.string.select_background_image);
                break;
            case ADD_TO_PLAY_LIST_TAIL:
                title = resources.getString(R.string.add_to_play_list_tail);
                showSwitch = true;
                break;
            default:
                title = null;
                break;
        }
        if (title != null) {
            view = new SettingsView(title, summary, description, showSwitch, settingsItem);
        }
        //set view height
        int settingsHeight;
        if (settingsItem == ANIM_EFFECT) {
            settingsHeight = (int) resources.getDimension(R.dimen.anim_effect_settings_height);
            view.setViewHeight(settingsHeight);
        }
        return view;
    }

    public static class TimedOffItem {
        public static final int TIMING_SET = 0;
        public static final int TIMING_15 = 1;
        public static final int TIMING_30 = 2;
        public static final int TIMING_45 = 3;
        public static final int TIMING_60 = 4;

        public static final int TIMING_DEFAULT = TIMING_30;

        public static int getTimeDuration(int timingSet) {
            switch (timingSet) {
                case TIMING_15:
                    return 15 * 60 * 1000;
                case TIMING_30:
                    return 30 * 60 * 1000;
                case TIMING_45:
                    return 45 * 60 * 1000;
                case TIMING_60:
                    return 60 * 60 * 1000;
                case TIMING_SET:
                default:
                    return 0;
            }
        }
    }
}